/*
============================================================================
 Name        : BlockSearch.h
 Author      : 
 Version     :
 Copyright   : 
 Description : CBlockSearch declaration
============================================================================
*/

#ifndef BlockSearch_H
#define BlockSearch_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "Block.h"
#include "Global.h"
#include "Flickable.h"
// CLASS DECLARATION

/**
*  CBlockSearch
* 
*/
class CBlockSearch : public CBlock, public MFlickableCallback
{
public:
	~CBlockSearch();
	
	static CBlockSearch* NewL(CBaseBlock* bsBack);
	
	static CBlockSearch* NewLC(CBaseBlock* bsBack);

	CBlockSearch(CBaseBlock* bsBack);
	
public:

	void OnDraw(CFbsBitGc& g)const;

	void OnKeyDown(TInt keyCode);

	TBool ReadData(const TDesC8& aData);

	void WriteData(TDes8& aBuf);

	TInt GetDataLength();

	TInt16 GetDataType();

	void OnInput(const TDesC8& strInput);

	void ChangeScrollPos(TInt nPos);
	
	void OnMouseDown(const TPoint& aPt);

	void OnMouseMove(const TPoint& aPt);
	
	void OnMouseUp(const TPoint& aPt);
	
	void SizeChanged();
	
	static TInt OnDelay(TAny* aAny);
	
public:
	// from MFlickableCallback
	virtual TPoint ScrollOffset() const;

	virtual void SetScrollOffset(const TPoint& aOffset);
	
protected:
	void BeforeDraw(CFbsBitGc& g) const;
	
private:
	void ConstructL();

public:
	TBuf8<6> m_pbSearchInput;
	TInt8 m_bSearchStation;
	
private:
	RArray<TGoodsName>	m_pGN;
	TInt m_nCurrent;

	TBuf<32> m_bufMatching;
	TBuf<32> m_bufNoMatch;

	TInt iOffset;
	TInt iHeight;
	TInt iHighlight;
	CFlickable* iFlickable;
	TRect iListRect;

	mutable TInt iStartItem;
	mutable TInt iEndItem;
	
	CPeriodic* m_DelayTimer;
};

#endif // BlockSearch_H
